<template>
  <div class="container">
    <header>
      <div class="logo">
        <i class="fas fa-graduation-cap"></i>
        <span>学生信息管理系统</span>
      </div>
      <div class="user-info">
        <div class="avatar">张</div>
        <span>张老师</span>
        <button class="settings-btn">
          <i class="fas fa-cog"></i>
        </button>
      </div>
    </header>

    <main>
      <div class="card">
        <div class="toolbar">
          <div class="search-container">
            <i class="fas fa-search"></i>
            <input
              v-model="searchText"
              type="text"
              class="input-style"
              placeholder="搜索学号/姓名"
            >
          </div>
          <button
            @click="openAddModal"
            class="btn-primary"
          >
            <i class="fas fa-plus"></i>
            <span>新增学生</span>
          </button>
        </div>

        <div class="filters">
          <div class="relative">
            <button
              class="filter-btn"
              :class="{ active: filters.grade }"
              @click="toggleDropdown('grade')"
            >
              <span>{{ filters.grade || '全部年级' }}</span>
              <i class="fas fa-chevron-down"></i>
            </button>
            <transition name="dropdown">
              <div
                v-if="dropdowns.grade"
                class="dropdown"
              >
                <div
                  class="dropdown-item"
                  :class="{ selected: !filters.grade }"
                  @click="selectFilter('grade', null)"
                >
                  全部年级
                </div>
                <div
                  v-for="grade in gradeOptions"
                  :key="grade"
                  class="dropdown-item"
                  :class="{ selected: filters.grade === grade }"
                  @click="selectFilter('grade', grade)"
                >
                  {{ grade }}
                </div>
              </div>
            </transition>
          </div>

          <div class="relative">
            <button
              class="filter-btn"
              :class="{ active: filters.clazz }"
              @click="toggleDropdown('clazz')"
            >
              <span>{{ filters.clazz || '全部班级' }}</span>
              <i class="fas fa-chevron-down"></i>
            </button>
            <transition name="dropdown">
              <div
                v-if="dropdowns.clazz"
                class="dropdown"
              >
                <div
                  class="dropdown-item"
                  :class="{ selected: !filters.clazz }"
                  @click="selectFilter('clazz', null)"
                >
                  全部班级
                </div>
                <div
                  v-for="clazz in clazzOptions"
                  :key="clazz"
                  class="dropdown-item"
                  :class="{ selected: filters.clazz === clazz }"
                  @click="selectFilter('clazz', clazz)"
                >
                  {{ clazz }}
                </div>
              </div>
            </transition>
          </div>

          <div class="relative">
            <button
              class="filter-btn"
              :class="{ active: filters.gender }"
              @click="toggleDropdown('gender')"
            >
              <span>{{ filters.gender || '全部性别' }}</span>
              <i class="fas fa-chevron-down"></i>
            </button>
            <transition name="dropdown">
              <div
                v-if="dropdowns.gender"
                class="dropdown"
              >
                <div
                  class="dropdown-item"
                  :class="{ selected: !filters.gender }"
                  @click="selectFilter('gender', null)"
                >
                  全部性别
                </div>
                <div
                  v-for="gender in genderOptions"
                  :key="gender"
                  class="dropdown-item"
                  :class="{ selected: filters.gender === gender }"
                  @click="selectFilter('gender', gender)"
                >
                  {{ gender }}
                </div>
              </div>
            </transition>
          </div>

          <button
            @click="resetFilters"
            class="reset-btn"
          >
            <i class="fas fa-redo-alt"></i>
            <span>重置</span>
          </button>
        </div>

        <div class="table-container">
          <table>
            <thead>
              <tr>
                <th v-for="header in tableHeaders" :key="header">{{ header }}</th>
              </tr>
            </thead>
            <tbody>
              <tr v-if="filteredStudents.length === 0">
                <td :colspan="tableHeaders.length" class="empty-state">
                  <i class="fas fa-user-graduate"></i>
                  <p>没有找到学生数据</p>
                </td>
              </tr>
              <tr
                v-else
                v-for="(student, index) in paginatedStudents"
                :key="student.id"
              >
                <td>{{ (currentPage - 1) * pageSize + index + 1 }}</td>
                <td>{{ student.id }}</td>
                <td>{{ student.name }}</td>
                <td>{{ student.clas__name }}</td>
<!--                <td>{{ student.grade }}</td>-->
<!--                <td>{{ student.clazz }}</td>-->
<!--                <td>{{ student.phone }}</td>-->
                <td>
                  <div class="action-buttons">
                    <button
                      @click="editStudent(student)"
                      class="action-btn edit-btn"
                    >
                      <i class="fas fa-edit"></i>
                      <span>编辑</span>
                    </button>
                    <button
                      @click="deleteStudent(student.id)"
                      class="action-btn delete-btn"
                    >
                      <i class="fas fa-trash-alt"></i>
                      <span>删除</span>
                    </button>
                  </div>
                </td>
              </tr>
            </tbody>
          </table>
        </div>

        <div class="pagination">
          <div class="pagination-info">
            共 {{ filteredStudents.length }} 条记录
          </div>
          <div class="pagination-controls">
            <button
              class="page-btn"
              @click="prevPage"
              :disabled="currentPage === 1"
            >
              <i class="fas fa-chevron-left"></i>
            </button>

            <button
              v-for="page in visiblePages"
              :key="page"
              class="page-btn"
              :class="{ active: currentPage === page }"
              @click="currentPage = page"
            >
              {{ page }}
            </button>

            <button
              class="page-btn"
              @click="nextPage"
              :disabled="currentPage === totalPages"
            >
              <i class="fas fa-chevron-right"></i>
            </button>

            <div class="page-size-selector relative">
              <button
                class="filter-btn"
                @click="toggleDropdown('pageSize')"
              >
                <span>{{ pageSize }} 条/页</span>
                <i class="fas fa-chevron-down"></i>
              </button>
              <transition name="dropdown">
                <div
                  v-if="dropdowns.pageSize"
                  class="dropdown"
                >
                  <div
                    v-for="size in [5, 10, 20]"
                    :key="size"
                    class="dropdown-item"
                    :class="{ selected: pageSize === size }"
                    @click="changePageSize(size)"
                  >
                    {{ size }} 条/页
                  </div>
                </div>
              </transition>
            </div>
          </div>
        </div>
      </div>
    </main>

    <transition name="fade">
      <div
        v-if="showModal"
        class="modal-overlay"
        @click.self="closeModal"
      >
        <div class="modal-content">
          <div class="modal-header">
            <h3 class="modal-title">{{ isEditing ? '编辑学生信息' : '新增学生信息' }}</h3>
            <button
              @click="closeModal"
              class="modal-close"
            >
              <i class="fas fa-times"></i>
            </button>
          </div>

          <div class="modal-body">
            <div class="form-grid">
              <!-- 学号字段 -->
              <div class="form-group">
                <label class="form-label">
                  学号 <span class="required">*</span>
                </label>
                <input
                  v-model="formData.id"
                  type="text"
                  class="input-style"
                  placeholder="请输入学号"
                >
                <div v-if="errors.id" class="error-text">{{ errors.id }}</div>
              </div>

              <!-- 姓名字段 -->
              <div class="form-group">
                <label class="form-label">
                  姓名 <span class="required">*</span>
                </label>
                <input
                  v-model="formData.name"
                  type="text"
                  class="input-style"
                  placeholder="请输入姓名"
                >
                <div v-if="errors.name" class="error-text">{{ errors.name }}</div>
              </div>

              <!-- 性别选择 -->
              <div class="form-group">
                <label class="form-label">
                  性别 <span class="required">*</span>
                </label>
                <div class="relative">
                  <button
                    class="filter-btn w-full"
                    @click="toggleDropdown('formGender')"
                  >
                    <span>{{ formData.gender || '请选择性别' }}</span>
                    <i class="fas fa-chevron-down"></i>
                  </button>
                  <transition name="dropdown">
                    <div
                      v-if="dropdowns.formGender"
                      class="dropdown"
                    >
                      <div
                        v-for="option in genderOptions"
                        :key="option"
                        class="dropdown-item"
                        :class="{ selected: formData.gender === option }"
                        @click="selectFormOption('gender', option)"
                      >
                        {{ option }}
                      </div>
                    </div>
                  </transition>
                </div>
                <div v-if="errors.gender" class="error-text">{{ errors.gender }}</div>
              </div>

              <!-- 年级选择 -->
              <div class="form-group">
                <label class="form-label">
                  年级 <span class="required">*</span>
                </label>
                <div class="relative">
                  <button
                    class="filter-btn w-full"
                    @click="toggleDropdown('formGrade')"
                  >
                    <span>{{ formData.grade || '请选择年级' }}</span>
                    <i class="fas fa-chevron-down"></i>
                  </button>
                  <transition name="dropdown">
                    <div
                      v-if="dropdowns.formGrade"
                      class="dropdown"
                    >
                      <div
                        v-for="option in gradeOptions"
                        :key="option"
                        class="dropdown-item"
                        :class="{ selected: formData.grade === option }"
                        @click="selectFormOption('grade', option)"
                      >
                        {{ option }}
                      </div>
                    </div>
                  </transition>
                </div>
                <div v-if="errors.grade" class="error-text">{{ errors.grade }}</div>
              </div>

              <!-- 班级选择 -->
              <div class="form-group">
                <label class="form-label">
                  班级 <span class="required">*</span>
                </label>
                <div class="relative">
                  <button
                    class="filter-btn w-full"
                    @click="toggleDropdown('formClazz')"
                  >
                    <span>{{ formData.clazz || '请选择班级' }}</span>
                    <i class="fas fa-chevron-down"></i>
                  </button>
                  <transition name="dropdown">
                    <div
                      v-if="dropdowns.formClazz"
                      class="dropdown"
                    >
                      <div
                        v-for="option in clazzOptions"
                        :key="option"
                        class="dropdown-item"
                        :class="{ selected: formData.clazz === option }"
                        @click="selectFormOption('clazz', option)"
                      >
                        {{ option }}
                      </div>
                    </div>
                  </transition>
                </div>
                <div v-if="errors.clazz" class="error-text">{{ errors.clazz }}</div>
              </div>

              <!-- 联系方式 -->
              <div class="form-group">
                <label class="form-label">
                  联系方式 <span class="required">*</span>
                </label>
                <input
                  v-model="formData.phone"
                  type="tel"
                  class="input-style"
                  placeholder="请输入手机号"
                >
                <div v-if="errors.phone" class="error-text">{{ errors.phone }}</div>
              </div>
            </div>
          </div>

          <div class="modal-footer">
            <button
              @click="closeModal"
              class="btn-secondary"
            >
              取消
            </button>
            <button
              @click="handleSubmit"
              class="btn-primary"
            >
              确定
            </button>
          </div>
        </div>
      </div>
    </transition>
  </div>
</template>

<script setup>
import { ref, reactive, computed, watch, onMounted } from 'vue';
import requestUtil from '@/util/request'


const students = ref([])

// 状态管理
const searchText = ref('');
const showModal = ref(false);
const isEditing = ref(false);
const currentPage = ref(1);
const pageSize = ref(10);

// 下拉菜单状态
const dropdowns = reactive({
  grade: false,
  clazz: false,
  gender: false,
  pageSize: false,
  formGender: false,
  formGrade: false,
  formClazz: false
});
// aioxs

// 表单数据
const initialFormState = {
  id: '',
  name: '',
  gender: '',
  grade: '',
  clazz: '',
  phone: ''
};

const formData = reactive({...initialFormState});

console.log(initialFormState)

// 错误信息
const errors = reactive({
  id: '',
  name: '',
  gender: '',
  grade: '',
  clazz: '',
  phone: ''
});

// 验证规则
const validationRules = {
  id: [
    { required: true, message: '学号不能为空' },
    { pattern: /^\d{7}$/, message: '学号必须是7位数字' }
  ],
  name: [{ required: true, message: '姓名不能为空' }],
  gender: [{ required: true, message: '请选择性别' }],
  grade: [{ required: true, message: '请选择年级' }],
  clazz: [{ required: true, message: '请选择班级' }],
  phone: [
    { required: true, message: '手机号不能为空' },
    { pattern: /^1[3-9]\d{9}$/, message: '请输入有效的手机号' }
  ]
};

// 过滤条件
const filters = reactive({
  grade: '',
  clazz: '',
  gender: ''
});

// 选项数据
const tableHeaders = ['序号', '学号', '姓名', '班级', '操作'];
const gradeOptions = ['高一', '高二', '高三'];
const clazzOptions = ['1班', '2班', '3班', '4班'];
const genderOptions = ['男', '女'];

// 计算属性
const filteredStudents = computed(() => {
  return students.value.filter(student => {
    const matchesSearch = !searchText.value ||
      student.id.includes(searchText.value) ||
      student.name.includes(searchText.value);

    const matchesGrade = !filters.grade || student.grade === filters.grade;
    const matchesClazz = !filters.clazz || student.clazz === filters.clazz;
    const matchesGender = !filters.gender || student.gender === filters.gender;

    return matchesSearch && matchesGrade && matchesClazz && matchesGender;
  });
});

const totalPages = computed(() => {
  return Math.ceil(filteredStudents.value.length / pageSize.value);
});

const paginatedStudents = computed(() => {
  const start = (currentPage.value - 1) * pageSize.value;
  const end = start + pageSize.value;
  return filteredStudents.value.slice(start, end);
});

const visiblePages = computed(() => {
  const pages = [];
  const maxVisible = 5;
  let startPage = 1;
  let endPage = Math.min(totalPages.value, maxVisible);

  if (totalPages.value > maxVisible) {
    const half = Math.floor(maxVisible / 2);
    if (currentPage.value <= half) {
      endPage = maxVisible;
    } else if (currentPage.value >= totalPages.value - half) {
      startPage = totalPages.value - maxVisible + 1;
    } else {
      startPage = currentPage.value - half;
      endPage = currentPage.value + half;
    }

    // 确保页码范围不越界
    endPage = Math.min(endPage, totalPages.value);
  }

  for (let i = startPage; i <= endPage; i++) {
    pages.push(i);
  }

  return pages;
});

// 方法
function toggleDropdown(dropdownName) {
  // 关闭所有其他下拉菜单
  Object.keys(dropdowns).forEach(key => {
    if (key !== dropdownName) dropdowns[key] = false;
  });
  // 切换当前下拉菜单
  dropdowns[dropdownName] = !dropdowns[dropdownName];
}

function selectFilter(type, value) {
  filters[type] = value;
  dropdowns[type] = false;
  currentPage.value = 1;
}

function selectFormOption(type, value) {
  formData[type] = value;
  dropdowns[`form${type.charAt(0).toUpperCase() + type.slice(1)}`] = false;
  validateField(type, value);
}

function resetFilters() {
  filters.grade = '';
  filters.clazz = '';
  filters.gender = '';
  searchText.value = '';
  currentPage.value = 1;
}

function changePageSize(size) {
  pageSize.value = size;
  currentPage.value = 1;
  dropdowns.pageSize = false;
}

function prevPage() {
  if (currentPage.value > 1) currentPage.value--;
}

function nextPage() {
  if (currentPage.value < totalPages.value) currentPage.value++;
}

function openAddModal() {
  resetForm();
  isEditing.value = false;
  showModal.value = true;
}

function editStudent(student) {
  Object.assign(formData, student);
  isEditing.value = true;
  showModal.value = true;
}

function resetForm() {
  Object.assign(formData, initialFormState);
  Object.keys(errors).forEach(key => errors[key] = '');
}

function validateForm() {
  let isValid = true;
  Object.keys(errors).forEach(key => errors[key] = '');

  Object.keys(validationRules).forEach(field => {
    const rules = validationRules[field];
    rules.forEach(rule => {
      if (rule.required && !formData[field]) {
        errors[field] = rule.message;
        isValid = false;
      } else if (rule.pattern && formData[field] && !rule.pattern.test(formData[field])) {
        errors[field] = rule.message;
        isValid = false;
      }
    });
  });

  return isValid;
}

function validateField(field, value) {
  const rules = validationRules[field];
  if (!rules) return;

  errors[field] = '';

  for (const rule of rules) {
    if (rule.required && !value) {
      errors[field] = rule.message;
      break;
    } else if (rule.pattern && value && !rule.pattern.test(value)) {
      errors[field] = rule.message;
      break;
    }
  }
}

function handleSubmit() {
  if (!validateForm()) return;

  if (isEditing.value) {
    const index = students.value.findIndex(s => s.id === formData.id);
    if (index !== -1) students.value[index] = {...formData};
  } else {
    if (students.value.some(s => s.id === formData.id)) {
      errors.id = '该学号已存在';
      return;
    }
    students.value.push({...formData});
  }
  closeModal();
}

function deleteStudent(id) {
  if (confirm('确定要删除该学生吗？')) {
    students.value = students.value.filter(student => student.id !== id);
    // 如果删除后当前页没有数据且不是第一页，则返回上一页
    if (paginatedStudents.value.length === 0 && currentPage.value > 1) {
      currentPage.value--;
    }
  }
}

function closeModal() {
  showModal.value = false;
  // 关闭所有下拉菜单
  Object.keys(dropdowns).forEach(key => dropdowns[key] = false);
}

// 监听器
watch(filters, () => currentPage.value = 1);
watch(pageSize, () => currentPage.value = 1);

// 请求加载的数据
onMounted(async () =>{
const results = await requestUtil.get('stu/msg');
const data = results.data.data;
students.value = data;
console.log(data)})

// onMounted(async () =>{
// const results = await requestUtil.post('stu/msg',);


// console.log(data)})


</script>

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
}

:root {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --secondary: #f3f4f6;
  --secondary-hover: #e5e7eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --radius: 8px;
}

body {
  background-color: #f9fafb;
  color: var(--text);
}

.container {
  max-width: 1440px;
  margin: 0 auto;
  min-height: 100vh;
}

/* 头部样式 */
header {
  background: white;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.25rem;
  font-weight: 600;
}

.logo i {
  color: var(--primary);
  font-size: 1.5rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background-color: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-weight: bold;
}

.settings-btn {
  color: var(--text-light);
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  transition: color 0.2s;
}

.settings-btn:hover {
  color: var(--primary);
}

/* 主要内容样式 */
main {
  padding: 24px;
}

.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* 工具栏样式 */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.search-container {
  position: relative;
  width: 300px;
}

.search-container i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
}

.input-style {
  width: 100%;
  height: 40px;
  padding: 0 16px 0 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  transition: border-color 0.2s;
}

.input-style:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.btn-primary {
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 0 16px;
  height: 40px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.2s;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

/* 过滤栏样式 */
.filters {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.filter-btn {
  width: 160px;
  height: 40px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 0.875rem;
  color: var(--text-light);
  cursor: pointer;
  position: relative;
}

.filter-btn.active {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-btn.w-full {
  width: 100%;
}

.reset-btn {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color 0.2s;
}

.reset-btn:hover {
  color: var(--primary);
}

/* 下拉菜单样式 */
.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  z-index: 10;
  max-height: 240px;
  overflow-y: auto;
}

.dropdown-item {
  padding: 12px 16px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.dropdown-item:hover {
  background-color: var(--secondary);
}

.dropdown-item.selected {
  color: var(--primary);
  font-weight: 500;
}

/* 表格样式 */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}

th {
  background-color: #f9fafb;
  padding: 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 16px;
  font-size: 0.875rem;
  border-top: 1px solid var(--border);
}

tr:nth-child(even) {
  background-color: #fafafa;
}

tr:hover {
  background-color: #f0f9ff;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.action-btn {
  background: none;
  border: none;
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
}

.edit-btn {
  color: var(--primary);
}

.edit-btn:hover {
  color: var(--primary-hover);
}

.delete-btn {
  color: var(--danger);
}

.delete-btn:hover {
  color: var(--danger-hover);
}

/* 分页样式 */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.pagination-info {
  font-size: 0.875rem;
  color: var(--text-light);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.page-btn.active {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
}

.page-size-selector {
  position: relative;
  width: 120px;
}

/* 模态框样式 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: var(--radius);
  width: 600px;
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-light);
  cursor: pointer;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.form-label .required {
  color: var(--danger);
}

.error-text {
  color: var(--danger);
  font-size: 0.75rem;
  margin-top: 4px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.btn-secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 20px;
  height: 40px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background-color: var(--secondary);
}

/* 空状态样式 */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-light);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 16px;
  color: #d1d5db;
}

/* 辅助类 */
.relative {
  position: relative;
}

.w-full {
  width: 100%;
}

/* 响应式调整 */
@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-container {
    width: 100%;
  }

  .filters {
    flex-direction: column;
  }

  .filter-btn {
    width: 100%;
  }

  .pagination {
    flex-direction: column;
    align-items: center;
  }
}

/* 动画效果 */
.fade-enter-active, .fade-leave-active {
  transition: opacity 0.3s;
}

.fade-enter-from, .fade-leave-to {
  opacity: 0;
}

.dropdown-enter-active, .dropdown-leave-active {
  transition: all 0.2s ease;
}

.dropdown-enter-from, .dropdown-leave-to {
  opacity: 0;
  transform: translateY(-10px);
}
</style>